package com.jwaoo.chat.session.avchat;

import android.view.animation.Interpolator;

import com.dx.as.common.string.StringUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

/**
 * Created by jwaoo on 2017/11/8.
 */

public class MessageParse {

    private static Gson gson = new Gson();

    public static String createInteractMessage(InteractInfo info){
        return gson.toJson(info);
    }

    public static InteractInfo parseDate(String json){
        if (StringUtil.isEmpty(json)) return null;
        InteractInfo info = gson.fromJson(json,new TypeToken<InteractInfo>(){}.getType());
        return info;

    }

    public static int getDivtype(String name){
        if (name.toLowerCase().contains("SenseBand".toLowerCase())) return InteractInfo.DIV_TYPE_SENSE_BAND;
        else if (name.toLowerCase().contains("Sensevibe".toLowerCase())) return InteractInfo.DIV_TYPE_SENSE_VIBE;
        else return InteractInfo.DIV_TYPE_SENSE_WARM;
    }

    public static class InteractInfo{
        public static final int DIV_TYPE_SENSE_WARM = 1;
        public static final int DIV_TYPE_SENSE_BAND = 3; //手环
        public static final int DIV_TYPE_SENSE_VIBE = 2; //震动棒
        public static final int STATE_ONLINE = 1; //在线状态
        public static final int STATE_OFFLINE = 0; //在线状态
        public static final int MSG_TYPE_ONLINE_STATE = 1; //在线状态
        public static final int MSG_TYPE_REQUEST = 2; //请求控制
        public static final int MSG_TYPE_ACTION = 3; //控制消息
        public static final int REQUSET_TYPE_REJECT = 2; //拒绝请求
        public static final int REQUSET_TYPE_ACCEPT = 1; //接受请求

        private int divtype; //1,飞机杯，2，震动棒 3,手环
        private int divmode; //模式
        private int level;//级别
        private String msg;
        private int msgtype;//1:在线状态，2:请求控制权限,3:控制消息
        private int online;
        private int request_state;//0:请求，1，接受，2，拒绝
        private boolean isSpeedByFreq; //是否是运动状态

        public boolean isSpeedByFreq() {
            return isSpeedByFreq;
        }

        public void setSpeedByFreq(boolean speedByFreq) {
            isSpeedByFreq = speedByFreq;
        }

        public int getDivtype() {
            return divtype;
        }

        public void setDivtype(int divtype) {
            this.divtype = divtype;
        }

        public int getRequest_state() {
            return request_state;
        }

        public void setRequest_state(int request_state) {
            this.request_state = request_state;
        }

        public int getDivmode() {
            return divmode;
        }

        public void setDivmode(int divmode) {
            this.divmode = divmode;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public int getMsgtype() {
            return msgtype;
        }

        public void setMsgtype(int msgtype) {
            this.msgtype = msgtype;
        }

        public int getOnline() {
            return online;
        }

        public void setOnline(int online) {
            this.online = online;
        }

    }

}
